package com.kexun.controller;

import com.kexun.annotation.RequestBody;
import com.kexun.annotation.RequestMapping;
import com.kexun.annotation.ResponseBody;
import com.kexun.entity.Manage;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

public class IndexController {

    //
    @RequestMapping("index")
    public String index(HttpServletRequest request, String username, Integer age) throws Exception {
        request.setAttribute("username", username);
        request.setAttribute("age", age);
        return "index";
    }

    @ResponseBody
    @RequestMapping("addManage")
    public Map<String, Object> addManage(Manage manage) throws Exception {
        System.out.println("manage:" + manage);
        Map<String, Object> result = new HashMap<>();
        result.put("code", 0);
        result.put("message", "添加成功");
        return result;
    }

    @ResponseBody
    @RequestMapping("addManageJSON")
    public Map<String, Object> addManageJSON(@RequestBody Manage manage) throws Exception {
        System.out.println("manage:" + manage);
        Map<String, Object> result = new HashMap<>();
        result.put("code", 0);
        result.put("message", "添加成功");
        return result;
    }


}
